package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

class zac {
   private com.aspose.cells.b.a.d.zh a;
   private int b;
   private ActiveXControl c;
   private ArrayList d;
   private ArrayList e;
   private byte[][] f;

   zac(ActiveXControl var1) {
      this.c = var1;
   }

   byte[] a() throws Exception {
      if (this.c.getType() == 11) {
         UnknownControl var2 = (UnknownControl)this.c;
         return var2.f;
      } else {
         this.a = new com.aspose.cells.b.a.d.zh();
         this.d = new ArrayList();
         this.e = new ArrayList();
         this.f = new byte[4][];
         this.f[1] = new byte[1];
         this.f[2] = new byte[2];
         this.f[3] = new byte[3];
         this.a.b(this.c.c, 0, 16);
         switch(this.c.getType()) {
         case 0:
         case 7:
            this.b();
            break;
         case 1:
         case 2:
         case 3:
         case 4:
         case 6:
         case 9:
            this.c();
            break;
         case 5:
         case 10:
            this.f();
            break;
         case 8:
            this.e();
         }

         this.a.b();
         byte[] var1 = this.a.o();
         return var1;
      }
   }

   private void b() throws Exception {
      zaa var1 = this.c.e;
      this.h();
      this.a(this.c.d);
      if (this.c.c(3)) {
         this.a(var1.b);
      }

      if (this.c.c(4)) {
         this.a(var1.c);
      }

      if (this.c.c(14)) {
         this.a(var1.a);
      }

      if (this.c.c(16)) {
         this.a(var1.n);
      }

      if (this.c.c(12)) {
         this.a(var1.l);
      }

      if (this.c.c(8)) {
         this.j();
      }

      if (this.c.c(5)) {
         this.a(var1.g);
      }

      if (this.c.getType() == 7) {
         if (this.c.c(2)) {
            this.a(var1.e);
         }

         if (this.c.c(1)) {
            this.a((short)(var1.d & 255));
         }

         if (this.c.c(7)) {
            this.a((short)(var1.f & 255));
         }
      }

      if (this.c.c(9)) {
         this.a(var1.j);
      }

      if (this.c.c(0)) {
         this.a((short)var1.m);
      }

      if (this.c.c(15)) {
         this.a(var1.k);
      }

      this.m();
      this.l();
      this.i();
      this.k();
      this.g();
   }

   private void c() throws Exception {
      zanp var1 = (zanp)this.c.e;
      this.h();
      int var2 = this.c.d;
      int var3 = zanp.b(41);
      boolean var4 = false;
      if ((var2 & var3) != 0) {
         var2 &= ~var3;
         var4 = true;
      }

      this.a(var2);
      this.a(var4 ? 1 : 0);
      if (this.c.c(14)) {
         this.a(var1.a);
      }

      if (this.c.c(4)) {
         this.a(var1.c);
      }

      if (this.c.c(3)) {
         this.a(var1.b);
      }

      if (this.c.c(25)) {
         this.a(var1.r);
      }

      if (this.c.c(1)) {
         this.a(var1.d);
      }

      if (this.c.c(26)) {
         this.a(var1.s);
      }

      if (this.c.c(27)) {
         this.a(var1.t);
      }

      if (this.c.c(5)) {
         this.a(var1.g);
      }

      if (this.c.c(8)) {
         this.j();
      }

      if (this.c.c(28)) {
         this.a((short)var1.u);
      }

      if (this.c.c(29)) {
         this.a(var1.v);
      }

      if (this.c.c(30)) {
         this.a((short)var1.w);
      }

      if (this.c.c(31)) {
         this.a((short)var1.x);
      }

      if (this.c.c(32)) {
         this.a((short)var1.y);
      }

      if (this.c.c(33)) {
         this.a((short)var1.z);
      }

      if (this.c.c(34)) {
         this.a((short)var1.A);
      }

      if (this.c.c(35)) {
         this.a(var1.B);
      }

      if (this.c.c(36)) {
         this.a(var1.C);
      }

      if (this.c.c(37)) {
         this.a(var1.D);
      }

      if (this.c.c(38)) {
         this.a(var1.E);
      }

      if (this.c.c(39)) {
         this.a(var1.F);
      }

      if (this.c.c(40)) {
         this.a(var1.G);
      }

      if (this.c.c(16)) {
         this.a(var1.n);
      }

      if (this.c.c(12)) {
         this.a(var1.l);
      }

      if (this.c.c(2)) {
         this.a(var1.e);
      }

      if (this.c.c(7)) {
         this.a(var1.f & 255);
      }

      if (this.c.c(15)) {
         this.a(var1.k);
      }

      if (this.c.c(9)) {
         this.a(var1.j);
      }

      if (this.c.c(0)) {
         this.a((short)var1.m);
      }

      if (this.c.c(41)) {
         this.a(var1.H);
      }

      this.m();
      this.l();
      this.i();
      this.k();
      this.g();
      this.d();
   }

   private void d() throws Exception {
      zanp var1 = (zanp)this.c.e;
      if (var1.J != -1 && var1.c(42)) {
         this.h();
         this.a(var1.I);
         this.a(var1.J);
         this.i();
      }

   }

   private void e() throws Exception {
      zaa var1 = this.c.e;
      this.h();
      this.a(this.c.d);
      if (this.c.c(2)) {
         this.a(var1.e);
      }

      if (this.c.c(4)) {
         this.a(var1.c);
      }

      if (this.c.c(1)) {
         this.a(var1.d);
      }

      if (this.c.c(5)) {
         this.a(var1.g);
      }

      if (this.c.c(6)) {
         this.a(var1.o);
      }

      if (this.c.c(7)) {
         this.a(var1.f);
      }

      if (this.c.c(8)) {
         this.j();
      }

      if (this.c.c(9)) {
         this.a(var1.j);
      }

      if (this.c.c(10)) {
         this.a(var1.p);
      }

      if (this.c.c(14)) {
         this.a(var1.a);
      }

      if (this.c.c(15)) {
         this.a(var1.k);
      }

      this.m();
      this.l();
      this.i();
      this.k();
   }

   private void f() throws Exception {
      zbce var1 = (zbce)this.c.e;
      this.h();
      this.a(this.c.d);
      if (this.c.c(3)) {
         this.a(var1.b);
      }

      if (this.c.c(4)) {
         this.a(var1.c);
      }

      if (this.c.c(14)) {
         this.a(var1.a);
      }

      if (this.c.c(8)) {
         this.j();
      }

      if (this.c.getType() == 10 && this.c.c(5)) {
         this.a(var1.g);
      }

      if (this.c.c(43)) {
         this.a(var1.s);
      }

      if (this.c.c(44)) {
         this.a(var1.r);
      }

      if (this.c.c(45)) {
         this.a(var1.t);
      }

      if (this.c.c(46)) {
         this.a(var1.u);
      }

      if (this.c.c(47)) {
         this.a(var1.v);
      }

      if (this.c.c(48)) {
         this.a(var1.w);
      }

      if (this.c.getType() == 10 && this.c.c(49)) {
         this.a(var1.x);
      }

      if (this.c.c(50)) {
         int var2 = var1.y == 3 ? -1 : var1.y & 255;
         this.a(var2);
      }

      if (this.c.getType() == 10 && this.c.c(51)) {
         this.a((short)var1.z);
      }

      if (this.c.c(52)) {
         this.a(var1.A);
      }

      if (this.c.c(15)) {
         this.a(var1.k);
      }

      if (this.c.getType() == 5 && this.c.c(5)) {
         this.a(var1.g);
      }

      this.m();
      this.l();
      this.i();
      this.k();
      this.g();
   }

   private void g() throws Exception {
      Font var1 = this.c.getFont();
      this.h();
      int var2 = 0;
      this.a((int)0);
      if (var1.f(13)) {
         this.a(var1.getName());
         var2 |= zad.b(17);
      }

      int var3 = 0;
      if (var1.isBold()) {
         var3 |= 1;
      }

      if (var1.isItalic()) {
         var3 |= 2;
      }

      if (var1.getUnderline() != 0) {
         var3 |= 4;
      }

      if (var1.isStrikeout()) {
         var3 |= 8;
      }

      if (var3 != 0) {
         this.a(var3);
         var2 |= zad.b(18);
      }

      if (var1.f(12)) {
         this.a(var1.i());
         var2 |= zad.b(19);
      }

      if (var1.f(15)) {
         this.a((byte)var1.getCharset());
         var2 |= zad.b(20);
      }

      if (var1.f(14)) {
         this.a(var1.d);
         var2 |= zad.b(21);
      }

      if (this.c.e.q != 0) {
         this.a(this.c.e.q);
         var2 |= zad.b(22);
      }

      if (var1.f(17)) {
         this.a((short)var1.g());
         var2 |= zad.b(23);
      }

      this.m();
      this.l();
      this.a.a((long)(-(this.b - 2)), 1);
      this.a.b(com.aspose.cells.b.a.zc.a((short)(this.b - 4)), 0, 2);
      this.a.b(com.aspose.cells.b.a.zc.a(var2), 0, 4);
      this.a.a((long)(this.b - 8), 1);
   }

   private void h() throws Exception {
      this.a.a((byte)0);
      this.a.a((byte)2);
      this.a.a(2L, 1);
      this.b = 4;
   }

   private void i() throws Exception {
      this.a.a((long)(-(this.b - 2)), 1);
      this.a.b(com.aspose.cells.b.a.zc.a((short)(this.b - 4)), 0, 2);
      this.a.a((long)(this.b - 4), 1);
   }

   private void j() {
      com.aspose.cells.b.a.a.ze.a(this.d, (Object)com.aspose.cells.b.a.zc.a(this.c.e.h));
      com.aspose.cells.b.a.a.ze.a(this.d, (Object)com.aspose.cells.b.a.zc.a(this.c.e.i));
   }

   private void a(byte[] var1) throws Exception {
      this.a((short)-1);
      com.aspose.cells.b.a.a.ze.a(this.e, (Object)var1);
   }

   private void k() throws Exception {
      Iterator var1 = this.e.iterator();

      while(var1.hasNext()) {
         byte[] var2 = (byte[])var1.next();
         this.a.b(zad.l, 0, 16);
         this.a.b(com.aspose.cells.b.a.zc.a((int)29804), 0, 4);
         this.a.b(com.aspose.cells.b.a.zc.a(var2.length), 0, 4);
         this.a.b(var2, 0, var2.length);
      }

   }

   private void l() throws Exception {
      Iterator var1 = this.d.iterator();

      while(var1.hasNext()) {
         byte[] var2 = (byte[])var1.next();
         if (var2 != null) {
            this.a.b(var2, 0, var2.length);
            this.b += var2.length;
         }
      }

      this.d.clear();
   }

   private void a(int var1) throws Exception {
      int var2 = zad.a(this.b, 4);
      if (var2 != 0) {
         this.a.a((long)var2, 1);
         this.b += var2;
      }

      this.a.b(com.aspose.cells.b.a.zc.a(var1), 0, 4);
      this.b += 4;
   }

   private void m() throws Exception {
      int var1 = zad.a(this.b, 4);
      if (var1 != 0) {
         this.a.a((long)var1, 1);
         this.b += var1;
      }

   }

   private void a(short var1) throws Exception {
      int var2 = zad.a(this.b, 2);
      if (var2 != 0) {
         this.a.a((long)var2, 1);
         this.b += var2;
      }

      this.a.b(com.aspose.cells.b.a.zc.a(var1), 0, 2);
      this.b += 2;
   }

   private void a(byte var1) throws Exception {
      this.a.a(var1);
      ++this.b;
   }

   private void a(String var1) throws Exception {
      byte[] var2 = zakq.a(var1);
      boolean var3 = var2.length == var1.length();
      int var4 = var1.length();
      var4 |= Integer.MIN_VALUE;
      this.a(var4);
      com.aspose.cells.b.a.a.ze.a(this.d, (Object)var2);
      int var5 = zad.a(var2.length, 4);
      if (var5 != 0) {
         com.aspose.cells.b.a.a.ze.a(this.d, (Object)this.f[var5]);
      }

   }
}
